
function y=DIF(w,N,P,X,Z)

    PZZ= calculatePZ(w,X,Z);
   
    y=0;
    for ii=1:9
        for jj=1:10
                   y = y + myfunc(ii,jj,N,P,PZZ);
        end
    end
end






function v1=myfunc(ii,jj,N,P,PZ)
    num = PZ(1,1,ii,jj);
    v1 =(N(11,4,ii+1,13).*(P(1,1,ii+1,jj+1)-num).^2)./(num.*(1-num));
end

